

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script type="text/javascript" src="helpman_topicinit.js"></script>

<title>Examples and Tips [Enterprise Architect User Guide]</title>

<meta name="keywords" content="Enterprise Architect, Sparx Systems, UML, Automation Interface,Automation Interface Examples and Tips,Examples And Tips,Examples And Tips Automation Interface">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<link type="text/css" href="default.css" rel="stylesheet" />
<style type="text/css">
  A, A:Visited
  {
    color: #00F;
  }

  A:Active, A:Hover
  {
    color: #F00;
  }

  OL
  {
    margin: 5px 0 5px 48px;
  }

  UL
  {
    margin-bottom: 3px;
    margin-top: 0;
  }

  #nsr
  {
    background-color: #D4DFFF;
  }

  #nsr A
  {
    text-decoration: none;
  }

  #mainbody
  {
    padding: 8px;
  }

  .p_BodyText
  {
    padding: 5px 0;
  }
</style>



<style type="text/css" media="screen">
  BODY
  {
    background-color: #FFFFFF;
  }

  #nsr
  {
    padding: 6px 6px 0 6px;
    border-bottom: none;
    vertical-align: top;
    z-index: 2;
    visibility: visible;
    left: 0;
    top: 0;
    position: absolute;
  }

  #mainbody
  {
    left: 0;
    top: 0;
    margin: 0;
    position: absolute;
    padding: 10px;
    overflow: auto;
    height: 100%;
    z-index: 1;
    background-repeat: no-repeat;
    background-position: bottom right;
    background-attachment: fixed;
  }
</style>

<style type="text/css" media="print">
  #nsr
  {
    visibility: none;
  }

  #mainbody
  {
    overflow: visible;
  }
</style>
<script type="text/javascript" language="JavaScript" src="nonscroll.js"></script>

</head>
<body scroll="no">

<div id="page">



        <div id="content">
          <div id="content-inner">
          



  
          <div id="nsr">
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
              <tr valign="top">
                <td align="left">
  


                  <p class="p_Heading1"><span class="f_Heading1">Examples and Tips</span></p>



  
                </td>
                <td align="right">
                  <a href="introduction.htm" onmouseover="document.images.main.src='button_main_h.gif'" onmouseout="document.images.main.src='button_main.gif'">
                    <img name="main" src="button_main.gif" border=0 alt="Return to Introduction">
                  </a>&nbsp;
    
                  <a href="setupvb.htm" onmouseover="document.images.prev.src='button_prev_h.gif'" onmouseout="document.images.prev.src='button_prev.gif'">
                    <img name=prev src="button_prev.gif" border=0 alt="Previous page" />
                  </a>&nbsp;
    
    
    
                  <a href="callfromea.htm" onmouseover="document.images.next.src='button_next_h.gif'" onmouseout="document.images.next.src='button_next.gif'">
                    <img name=next src="button_next.gif" border=0 alt="Next page" />
                  </a>
    
    
                </td>
              </tr>
            </table>
          </div>
          <div id="mainbody">
  


                <p class="p_BodyText"><span class="f_BodyText">Instructions for using the interface are provided through sample code. There are several sets of examples:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">VB 6 and C# examples are available in the </span><span class="f_Bulletlist1" style="font-style: italic;">Code Samples</span><span class="f_Bulletlist1"> folder under your Enterprise Architect installation (default: </span><span class="f_Code">C:\Program Files\Sparx Systems\EA\Code Samples</span><span class="f_Bulletlist1" style="font-style: italic;">)</span></li>
<li><span class="f_Bulletlist1">Enterprise Architect can be set up to <a href="callfromea.htm">call an external application</a></span></li>
<li><span class="f_Bulletlist1">Several VB.NET code snippets are provided in the <a href="codeexamples.htm">reference section</a></span></li>
<li><span class="f_Bulletlist1">A comprehensive example of using Visual Basic to create MS Word documentation is available from the internet at </span><span class="f_Bulletlist1"><a href="http://www.sparxsystems.com/resources/developers/autint_vb.html" target="_blank" class="weblink">www.sparxsystems.com/resources/developers/autint_vb.html</a></span></li>
<li><span class="f_Bulletlist1">Additional samples are available from the Sparx Systems website; see the </span><span class="f_Bulletlist1" style="font-style: italic;"><a href="availableresources.htm">Available Resources</a></span><span class="f_Bulletlist1"> topic.</span></li>
</ul>
<p class="p_BodyText"><span class="f_BodyText">&nbsp;</span></p>
<p class="p_BodyText"><span class="f_BodyText">Additionally, you should note the following tips and tricks:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">An instance of the Enterprise Architect (</span><span class="f_Code">EA.exe</span><span class="f_Bulletlist1">) process is executed when you initialize a new repository object. This process must remain running in order to perform automation tasks. If the main window is visible, you can safely minimize it, but it must remain running.</span></li>
<li><span class="f_Bulletlist1">The Enterprise Architect ActiveX Interface is a functional interface rather than a data interface. When you load data through the interface there is a noticeable delay as Enterprise Architect user interface elements (e.g. Windows, menus) are loaded and the specified database connection is established.</span></li>
<li><span class="f_Bulletlist1">Collections use a zero-based index; for example, </span><span class="f_Code">Repository.Models(0)</span><span class="f_Bulletlist1"> represents the first model in the repository.</span></li>
</ul>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">During the development of your client software your program might terminate unexpectedly and leave </span><span class="f_Code">EA.exe</span><span class="f_Bulletlist1"> running in such a state that it is unable to support further interface calls. If your program terminates abnormally, ensure that Enterprise Architect is not left running in the background (see the Windows </span><span class="f_UIControl">Task Manager / Process</span><span class="f_Bulletlist1"> tab).</span></li>
<li><span class="f_Bulletlist1">A handle to a currently running instance of Enterprise Architect can be obtained through the use of a </span><span class="f_Code">GetObject() </span><span class="f_Bulletlist1">call. For more information, refer to the reference page for the</span><span class="f_Bulletlist1" style="font-style: italic;"> <a href="app.htm">App</a></span><span class="f_Bulletlist1"> object. Accessing your Enterprise Architect model via the </span><span class="f_Bulletlist1" style="font-style: italic;">App</span><span class="f_Bulletlist1"> object enables querying the current User Interface status, such as using </span><span class="f_Code">GetContextItem()</span><span class="f_Bulletlist1" style="font-style: italic;"> </span><span class="f_Bulletlist1">on the <a href="repository3.htm">Repository</a> object to detect the current selection by the user, allowing for rapid prototyping and testing.</span></li>
</ul>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Enterprise Architect Not Closing</span></p>
<p class="p_BodyText"><span class="f_BodyText">If your automation controller was written using the .NET framework, Enterprise Architect does not close even after you release all your references to it. To force the release of the COM pointers, call the memory management functions as shown below:</span></p>
<p class="p_Code"><span class="f_Code"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GC.Collect();</span></p>
<p class="p_Code"><span class="f_Code"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GC.WaitForPendingFinalizers();</span></p>
<p class="p_BodyText"><span class="f_BodyText">There are additional concerns when controlling a running instance of Enterprise Architect that loads Add-Ins - see the </span><span class="f_BodyText" style="font-style: italic;"><a href="tricksandtraps.htm">Tricks and Traps</a></span><span class="f_BodyText"> topic for details.</span></p>




            </div>
          </div>
        </div>



</div>


</body>
</html>
